package com.hzf.wxplatform.web.controller.manager.material;

import com.google.gson.Gson;
import com.hzf.api.rpc.api.ApiService;
import com.hzf.cms.common.constant.CmsResult;
import com.hzf.cms.common.constant.CmsResultConstant;
import com.hzf.common.base.BaseController;
import com.hzf.common.face.*;
import com.hzf.common.face.faceModel.FaceEntity;
import com.hzf.common.util.*;
import com.hzf.ucenter.dao.model.*;
import com.hzf.upms.common.constant.UpmsResult;
import com.hzf.upms.common.constant.UpmsResultConstant;
import com.hzf.wxplatform.common.WxplatformResult;
import com.hzf.wxplatform.common.WxplatformResultConstant;
import com.hzf.wxplatform.common.utils.UcenterUserUtils;
import com.hzf.wxplatform.web.utils.SMSUtils;

import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.*;
/**
 * 材料商个人中心
 * Created by jiangxueli on 2017/11/24.
 */
@Controller
@RequestMapping("/materialUser")
public class MaterialUserController extends BaseController {
    @Autowired
    ApiService apiService;
    /**
     * 个人中心首页
     * @param request
     * @param model
     * @return
     */
    @RequestMapping(value = "/index")
    public String index(Model model, HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession();
        UcenterUser ucenterUser = new UcenterUser();
        byte[]user =  UcenterUserUtils.getUser(session);
        ucenterUser = (UcenterUser) ByteUtils.ByteToObject(user); if(null==ucenterUser){
            model.addAttribute("data","您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return  thymeleaf("/404");
        }
        System.out.println(ucenterUser.getAuthInfo());
        model.addAttribute("user", ucenterUser);
        return thymeleaf("/CLS/CLS_GR_Single");
    }

    @RequestMapping(value = "/account")
    public String account(Model model, HttpServletRequest request, HttpServletResponse response) {
        return thymeleaf("/CLS/CLS_Single");
    }

    @RequestMapping(value = "/account/bank")
    public String bank(Model model, HttpServletRequest request, HttpServletResponse response) {
        return thymeleaf("/CLS/CLS_Single_tianzhanghao");

    }


}
